package com.shop.zkmall.app.consumer;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.shop.zkmall.app.common.RocketConstants;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 注册完善用户信息消费者
 * @author heishe404
 * @date 2024/11/05 16:53
 **/
@Slf4j
@Component
@RocketMQMessageListener(topic = RocketConstants.USER_TOPIC, consumerGroup = "live-consumer")
public class UserRocketConsumer implements RocketMQListener<MessageExt> {


    @Override
    public void onMessage(MessageExt ext) {
        String body = new String(ext.getBody());
        JSONObject parse = JSONUtil.parseObj(body);
        String phone = parse.get("phone", String.class);
        log.info("【消费者】完善用户信息消息：消息体 => {}, tag => {}", body, ext.getTags());

    }
}
